package users

import (
	"api/internal/respons"
	"context"
	"fmt"
	"user_srv/userclient"

	"api/internal/svc"
	"api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type UserDetailLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewUserDetailLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UserDetailLogic {
	return &UserDetailLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

// 用户详情
func (l *UserDetailLogic) UserDetail(req *types.UserDetailRequest) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line
	detail, err := l.svcCtx.UserRpc.UserDetail(l.ctx, &userclient.UserDetailRequest{
		Mobile: req.Mobile,
	})
	if err != nil {
		return respons.Error(400, "服务端错误", err.Error()), err
	}
	fmt.Println(detail)
	return respons.Success(detail), nil

}
